1 /* 2 * This file is part of gtkD. 3 * 4 * gtkD is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU Lesser General Public License 6 * as published by the Free Software Foundation; either version 3 7 * of the License, or (at your option) any later version, with 8 * some exceptions, please read the COPYING file. 9 * 10 * gtkD is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public License 16 * along with gtkD; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 18 */ 19 20 // generated automatically - do not change 21 // find conversion definition on APILookup.txt 22 // implement new conversion functionalities on the wrap.utils pakage 23 24 25 module gdk.PaintableIF; 26 27 private import gdk.PaintableIF; 28 private import gdk.Snapshot; 29 private import gdk.c.functions; 30 public import gdk.c.types; 31 private import glib.ConstructionException; 32 private import gobject.ObjectG; 33 private import gobject.Signals; 34 private import std.algorithm; 35 36 37 /** 38 * `GdkPaintable` is a simple interface used by GTK to represent content that 39 * can be painted. 40 * 41 * The content of a `GdkPaintable` can be painted anywhere at any size 42 * without requiring any sort of layout. The interface is inspired by 43 * similar concepts elsewhere, such as 44 * [ClutterContent](https://developer.gnome.org/clutter/stable/ClutterContent.html), 45 * [HTML/CSS Paint Sources](https://www.w3.org/TR/css-images-4/#paint-source), 46 * or [SVG Paint Servers](https://www.w3.org/TR/SVG2/pservers.html). 47 * 48 * A `GdkPaintable` can be snapshot at any time and size using 49 * [method@Gdk.Paintable.snapshot]. How the paintable interprets that size and 50 * if it scales or centers itself into the given rectangle is implementation 51 * defined, though if you are implementing a `GdkPaintable` and don't know what 52 * to do, it is suggested that you scale your paintable ignoring any potential 53 * aspect ratio. 54 * 55 * The contents that a `GdkPaintable` produces may depend on the [class@GdkSnapshot] 56 * passed to it. For example, paintables may decide to use more detailed images 57 * on higher resolution screens or when OpenGL is available. A `GdkPaintable` 58 * will however always produce the same output for the same snapshot. 59 * 60 * A `GdkPaintable` may change its contents, meaning that it will now produce 61 * a different output with the same snapshot. Once that happens, it will call 62 * [method@Gdk.Paintable.invalidate_contents] which will emit the 63 * [signal@GdkPaintable::invalidate-contents] signal. If a paintable is known 64 * to never change its contents, it will set the %GDK_PAINTABLE_STATIC_CONTENTS 65 * flag. If a consumer cannot deal with changing contents, it may call 66 * [method@Gdk.Paintable.get_current_image] which will return a static 67 * paintable and use that. 68 * 69 * A paintable can report an intrinsic (or preferred) size or aspect ratio it 70 * wishes to be rendered at, though it doesn't have to. Consumers of the interface 71 * can use this information to layout thepaintable appropriately. Just like the 72 * contents, the size of a paintable can change. A paintable will indicate this 73 * by calling [method@Gdk.Paintable.invalidate_size] which will emit the 74 * [signal@GdkPaintable::invalidate-size] signal. And just like for contents, 75 * if a paintable is known to never change its size, it will set the 76 * %GDK_PAINTABLE_STATIC_SIZE flag. 77 * 78 * Besides API for applications, there are some functions that are only 79 * useful for implementing subclasses and should not be used by applications: 80 * [method@Gdk.Paintable.invalidate_contents], 81 * [method@Gdk.Paintable.invalidate_size], 82 * [func@Gdk.Paintable.new_empty]. 83 */ 84 public interface PaintableIF{ 85 /** Get the main Gtk struct */ 86 public GdkPaintable* getPaintableStruct(bool transferOwnership = false); 87 88 /** the main Gtk struct as a void* */ 89 protected void* getStruct(); 90 91 92 /** */ 93 public static GType getType() 94 { 95 return gdk_paintable_get_type(); 96 } 97 98 /** 99 * Compute a concrete size for the `GdkPaintable`. 100 * 101 * Applies the sizing algorithm outlined in the 102 * [CSS Image spec](https://drafts.csswg.org/css-images-3/#default-sizing) 103 * to the given @paintable. See that link for more details. 104 * 105 * It is not necessary to call this function when both @specified_width 106 * and @specified_height are known, but it is useful to call this 107 * function in GtkWidget:measure implementations to compute the 108 * other dimension when only one dimension is given. 109 * 110 * Params: 111 * specifiedWidth = the width @paintable could be drawn into or 112 * 0.0 if unknown 113 * specifiedHeight = the height @paintable could be drawn into or 114 * 0.0 if unknown 115 * defaultWidth = the width @paintable would be drawn into if 116 * no other constraints were given 117 * defaultHeight = the height @paintable would be drawn into if 118 * no other constraints were given 119 * concreteWidth = will be set to the concrete width computed 120 * concreteHeight = will be set to the concrete height computed 121 */ 122 public void computeConcreteSize(double specifiedWidth, double specifiedHeight, double defaultWidth, double defaultHeight, out double concreteWidth, out double concreteHeight); 123 124 /** 125 * Gets an immutable paintable for the current contents displayed by @paintable. 126 * 127 * This is useful when you want to retain the current state of an animation, 128 * for example to take a screenshot of a running animation. 129 * 130 * If the @paintable is already immutable, it will return itself. 131 * 132 * Returns: An immutable paintable for the current 133 * contents of @paintable 134 */ 135 public PaintableIF getCurrentImage(); 136 137 /** 138 * Get flags for the paintable. 139 * 140 * This is oftentimes useful for optimizations. 141 * 142 * See [flags@Gdk.PaintableFlags] for the flags and what they mean. 143 * 144 * Returns: The `GdkPaintableFlags` for this paintable 145 */ 146 public GdkPaintableFlags getFlags(); 147 148 /** 149 * Gets the preferred aspect ratio the @paintable would like to be displayed at. 150 * 151 * The aspect ratio is the width divided by the height, so a value of 0.5 152 * means that the @paintable prefers to be displayed twice as high as it 153 * is wide. Consumers of this interface can use this to preserve aspect 154 * ratio when displaying the paintable. 155 * 156 * This is a purely informational value and does not in any way limit the 157 * values that may be passed to [method@Gdk.Paintable.snapshot]. 158 * 159 * Usually when a @paintable returns nonzero values from 160 * [method@Gdk.Paintable.get_intrinsic_width] and 161 * [method@Gdk.Paintable.get_intrinsic_height] the aspect ratio 162 * should conform to those values, though that is not required. 163 * 164 * If the @paintable does not have a preferred aspect ratio, 165 * it returns 0. Negative values are never returned. 166 * 167 * Returns: the intrinsic aspect ratio of @paintable or 0 if none. 168 */ 169 public double getIntrinsicAspectRatio(); 170 171 /** 172 * Gets the preferred height the @paintable would like to be displayed at. 173 * 174 * Consumers of this interface can use this to reserve enough space to draw 175 * the paintable. 176 * 177 * This is a purely informational value and does not in any way limit the 178 * values that may be passed to [method@Gdk.Paintable.snapshot]. 179 * 180 * If the @paintable does not have a preferred height, it returns 0. 181 * Negative values are never returned. 182 * 183 * Returns: the intrinsic height of @paintable or 0 if none. 184 */ 185 public int getIntrinsicHeight(); 186 187 /** 188 * Gets the preferred width the @paintable would like to be displayed at. 189 * 190 * Consumers of this interface can use this to reserve enough space to draw 191 * the paintable. 192 * 193 * This is a purely informational value and does not in any way limit the 194 * values that may be passed to [method@Gdk.Paintable.snapshot]. 195 * 196 * If the @paintable does not have a preferred width, it returns 0. 197 * Negative values are never returned. 198 * 199 * Returns: the intrinsic width of @paintable or 0 if none. 200 */ 201 public int getIntrinsicWidth(); 202 203 /** 204 * Called by implementations of `GdkPaintable` to invalidate their contents. 205 * 206 * Unless the contents are invalidated, implementations must guarantee that 207 * multiple calls of [method@Gdk.Paintable.snapshot] produce the same output. 208 * 209 * This function will emit the [signal@Gdk.Paintable::invalidate-contents] 210 * signal. 211 * 212 * If a @paintable reports the %GDK_PAINTABLE_STATIC_CONTENTS flag, 213 * it must not call this function. 214 */ 215 public void invalidateContents(); 216 217 /** 218 * Called by implementations of `GdkPaintable` to invalidate their size. 219 * 220 * As long as the size is not invalidated, @paintable must return the same 221 * values for its intrinsic width, height and aspect ratio. 222 * 223 * This function will emit the [signal@Gdk.Paintable::invalidate-size] 224 * signal. 225 * 226 * If a @paintable reports the %GDK_PAINTABLE_STATIC_SIZE flag, 227 * it must not call this function. 228 */ 229 public void invalidateSize(); 230 231 /** 232 * Snapshots the given paintable with the given @width and @height. 233 * 234 * The paintable is drawn at the current (0,0) offset of the @snapshot. 235 * If @width and @height are not larger than zero, this function will 236 * do nothing. 237 * 238 * Params: 239 * snapshot = a `GdkSnapshot` to snapshot to 240 * width = width to snapshot in 241 * height = height to snapshot in 242 */ 243 public void snapshot(Snapshot snapshot, double width, double height); 244 245 /** 246 * Emitted when the contents of the @paintable change. 247 * 248 * Examples for such an event would be videos changing to the next frame or 249 * the icon theme for an icon changing. 250 */ 251 gulong addOnInvalidateContents(void delegate(PaintableIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0); 252 253 /** 254 * Emitted when the intrinsic size of the @paintable changes. 255 * 256 * This means the values reported by at least one of 257 * [method@Gdk.Paintable.get_intrinsic_width], 258 * [method@Gdk.Paintable.get_intrinsic_height] or 259 * [method@Gdk.Paintable.get_intrinsic_aspect_ratio] 260 * has changed. 261 * 262 * Examples for such an event would be a paintable displaying 263 * the contents of a toplevel surface being resized. 264 */ 265 gulong addOnInvalidateSize(void delegate(PaintableIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0); 266 }